package com.ojoin.trade.supplyloan_core.web.domain;

import java.util.Date;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

import org.hibernate.validator.constraints.NotBlank;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.ojoin.trade.common.utils.Config;
import com.ojoin.trade.common.utils.paynow.ThreeDESEncryptProvider;
import com.ojoin.trade.common.web.domain.IDentifiable;

@JsonIgnoreProperties(ignoreUnknown = true)
public class TbSlPlatformUserVO implements IDentifiable{
    private Integer id;

    private Integer idOfTbMerchantUser;

    private Integer platformRuleId;

    private String mhtname;
    
    private String mobile;
    
    private String platformName;

    private String platformCnname;
    
    private String loginUrl;
    
    private String username;

    private String password;
    //default(supplyloan)
    private String loginWay="default";

    //需要绑定支付宝 (1 需要, 0 不需要)
    private String bindAlipay;
    
	private String enableFlag;

    private String disableDate;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date rowUpdateTime;

    private Date rowCreateTime;

    private String verifyCodeCheck="0";

    private String certificateCheck="0";

    private String busiContract;
    
    @Max(value=90,message="融资折扣最高90%")
    @Min(value=30,message="融资折扣最低30%") 
    @NotBlank(message="融资折扣不能为空")
    private String discount;

    @NotBlank(message="融资日利率不能为空")
    private String rate;

    @NotBlank(message="融资手续费率不能为空")
    private String fee;

    @NotBlank(message="最高融资额度不能为空")
    private String maxAmount;
    
    @NotBlank(message="授信凭证不能为空")
    private String creditCertificate;
    
    private String creditcheckCertificate;
    
    private String loanPeriod;

    private Integer idOfFinaceaccount;

    private Integer loanstatus;
    
    @NotBlank(message="上下游合同到期日不能为空")
    private String contractExpireDate;

    public Integer getLoanstatus() {
        return loanstatus;
    }

    public void setLoanstatus(Integer loanstatus) {
        this.loanstatus = loanstatus;
    }

    public void setIdOfFinaceaccount(Integer idOfFinaceaccount) {
        this.idOfFinaceaccount = idOfFinaceaccount;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getIdOfTbMerchantUser() {
        return idOfTbMerchantUser;
    }

    public void setIdOfTbMerchantUser(Integer idOfTbMerchantUser) {
        this.idOfTbMerchantUser = idOfTbMerchantUser;
    }

    public Integer getPlatformRuleId() {
        return platformRuleId;
    }

    public void setPlatformRuleId(Integer platformRuleId) {
        this.platformRuleId = platformRuleId;
    }

    public String getMhtname() {
		return mhtname;
	}

	public void setMhtname(String mhtname) {
		this.mhtname = mhtname;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getPlatformCnname() {
        return platformCnname;
    }

    public void setPlatformCnname(String platformCnname) {
        this.platformCnname = platformCnname == null ? null : platformCnname.trim();
    }

    public String getPlatformName() {
        return platformName;
    }

    public void setPlatformName(String platformName) {
        this.platformName = platformName == null ? null : platformName.trim();
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username == null ? null : username.trim();
    }

    public String getPassword() {
    	return password;
    }

    public void setPassword(String password) {
        this.password = password == null ? null : password.trim();
    }
    
    public void encPassword(){
    	String DSEKey = Config.getProperty("ipaynow.dsekey");//3DES需要的key
        this.setPassword(getEncryptPwd(DSEKey));
    }

	private String getEncryptPwd(String DSEKey) {
		String newpwd = "";
		try {
			newpwd = ThreeDESEncryptProvider.encrypt(password,DSEKey);
		} catch(Exception e) {
		}
		return newpwd;
	}
    
    public void decPassword(){
    	String DSEKey = Config.getProperty("ipaynow.dsekey");//3DES需要的key
        this.setPassword(getDecryptPwd(DSEKey));
    }

    private String getDecryptPwd(String DSEKey) {
		String newpwd = "";
		try {
			newpwd = ThreeDESEncryptProvider.decrypt(password,DSEKey);
		} catch(Exception e) {
		}
		return newpwd;
	}
    
    public String getEnableFlag() {
        return enableFlag;
    }

    public void setEnableFlag(String enableFlag) {
        this.enableFlag = enableFlag;
    }

    public String getDisableDate() {
        return disableDate;
    }

    public void setDisableDate(String disableDate) {
        this.disableDate = disableDate == null ? null : disableDate.trim();
    }

    public Date getRowUpdateTime() {
        return rowUpdateTime;
    }

    public void setRowUpdateTime(Date rowUpdateTime) {
        this.rowUpdateTime = rowUpdateTime;
    }

    public Date getRowCreateTime() {
        return rowCreateTime;
    }

    public void setRowCreateTime(Date rowCreateTime) {
        this.rowCreateTime = rowCreateTime;
    }

    public String getVerifyCodeCheck() {
        return verifyCodeCheck;
    }

    public void setVerifyCodeCheck(String verifyCodeCheck) {
        this.verifyCodeCheck = verifyCodeCheck == null ? null : verifyCodeCheck.trim();
    }

    public String getCertificateCheck() {
        return certificateCheck;
    }

    public void setCertificateCheck(String certificateCheck) {
        this.certificateCheck = certificateCheck == null ? null : certificateCheck.trim();
    }
    
    public boolean isDefaultLoginWay(){
    	return "default".equals(getLoginWay());
    }
    
    public String getLoginWay() {
		return loginWay;
	}

	public void setLoginWay(String loginWay) {
		this.loginWay = loginWay;
	}

    public String getBusiContract() {
        return busiContract;
    }

    public void setBusiContract(String busiContract) {
        this.busiContract = busiContract == null ? null : busiContract.trim();
    }
    
    
	public String getLoginUrl() {
		return loginUrl;
	}

	public void setLoginUrl(String loginUrl) {
		this.loginUrl = loginUrl;
	}

	public String getDiscount() {
        return discount;
    }

    public void setDiscount(String discount) {
        this.discount = discount == null ? null : discount.trim();
    }

    public String getRate() {
        return rate;
    }

    public void setRate(String rate) {
        this.rate = rate == null ? null : rate.trim();
    }

    public String getFee() {
        return fee;
    }

    public void setFee(String fee) {
        this.fee = fee == null ? null : fee.trim();
    }

    public String getMaxAmount() {
        return maxAmount;
    }

    public void setMaxAmount(String maxAmount) {
        this.maxAmount = maxAmount == null ? null : maxAmount.trim();
    }
    
    public String getCreditCertificate() {
        return creditCertificate;
    }

    public void setCreditCertificate(String creditCertificate) {
        this.creditCertificate = creditCertificate == null ? null : creditCertificate.trim();
    }
    
    
	public String getLoanPeriod() {
		return loanPeriod;
	}

	public void setLoanPeriod(String loanPeriod) {
		this.loanPeriod = loanPeriod;
	}

	
	public String getCreditcheckCertificate() {
		return creditcheckCertificate;
	}

	public void setCreditcheckCertificate(String creditcheckCertificate) {
		this.creditcheckCertificate = creditcheckCertificate;
	}

	public Integer getIdOfFinaceaccount() {
		return idOfFinaceaccount;
	}
	
	public String getBindAlipay() {
		return bindAlipay;
	}

	public void setBindAlipay(String bindAlipay) {
		this.bindAlipay = bindAlipay;
	}

	public String getContractExpireDate() {
		return contractExpireDate;
	}

	public void setContractExpireDate(String contractExpireDate) {
		this.contractExpireDate = contractExpireDate;
	}

	@Override
	public String getTableName() {
		return "tb_sl_platform_user";
	}
	
}